from fastapi import APIRouter, Depends

from forward.api.admin.schemas.lucky.code import (
    ActivityCheckInSchema,
    CodeCompleCodeNoInSchema,
    CodeListInSchema,
    CodeResetInSchema,
    CodeStatisticsInSchema,
    CodeStatusInSchema,
)
from forward.api.admin.service.lucky.code import CodeService

code = APIRouter(prefix="/code")


@code.post("/lists")
async def lists(list_in: CodeListInSchema, code_service: CodeService = Depends()):
    """code lists

    Args:
        list_in (CodeListInSchema): _description_
        code_service (CodeService, optional): _description_. Defaults to Depends().

    Returns:
        _type_: _description_
    """

    return await code_service.lists(list_in)


# @code.post("/generate")
# async def generate(generate_in: GenerateInSchema, code_service: CodeService = Depends()):
#     return await code_service.generate(generate_in)


@code.post("/status")
async def status(status_in: CodeStatusInSchema, prize_service: CodeService = Depends()):
    return await prize_service.status(status_in)


# @code.post("/export")
# async def export(export_in: ActivityExportInSchema, prize_service: CodeService = Depends()):
#     return await prize_service.export(export_in)


@code.post("/check")
async def check_code(
    check_in: ActivityCheckInSchema, prize_service: CodeService = Depends()
):
    return await prize_service.check_code_is_empty(
        prefix=check_in.prefix,
        start_code_id=check_in.start_code_id,
        end_code_id=check_in.end_code_id,
    )


@code.post("/statistics")
async def get_code_statistics_by_activity_id(
    statistics_in: CodeStatisticsInSchema, code_service: CodeService = Depends()
):
    return await code_service.get_code_statistics_by_activity_id(
        statistics_in.activity_id
    )


@code.post("/comple_code_no")
async def autocomle_code_no(
    comple_code_no_in: CodeCompleCodeNoInSchema, code_service: CodeService = Depends()
):
    return await code_service.comple_code_no(comple_code_no_in)
